package com.cookie.framework.manager;

import android.content.Context;
import android.view.Gravity;

import com.cookie.framework.R;
import com.cookie.framework.view.DialogView;

/**
 * 项目名:    MeetProject
 * 包名:      com.cookie.framework.manager
 * 文件名:    DialogManager
 * 创建者:    cookie
 * 创建时间:   2020/1/1 14:25
 * 描述:      提示框管理类
 */

public class DialogManager {

    private static volatile DialogManager instance = null;

    private DialogManager() {

    }

    public static DialogManager getInstance() {
        if (instance == null) {
            synchronized (DialogManager.class) {
                if (instance == null) {
                    instance = new DialogManager();
                }
            }
        }
        return instance;
    }

    public DialogView initView(Context context, int layout) {
        return new DialogView(context, layout, R.style.Theme_Dialog, Gravity.CENTER);
    }

    public DialogView initView(Context context, int layout, int gravity) {
        return new DialogView(context, layout, R.style.Theme_Dialog, gravity);
    }

    public void show(DialogView view) {
        if (view != null) {
            if (!view.isShowing()) {
                view.show();
            }
        }
    }

    public void hide(DialogView view) {
        if (view != null && view.isShowing()) {
            view.dismiss();
        }
    }
}
